Fix tests on nightly
authorAlex Crichton <alex@alexcrichton.com>
Tue, 12 Jan 2016 17:47:31 +0000 (09:47 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 12 Jan 2016 17:47:31 +0000 (09:47 -0800)
tests/support/mod.rs
tests/test_cargo_compile.rs

index 00796905155ff37e0afdf4ade64584a1e1d8c27f..91c9a6888d2a0d84f6cddc189bdbca613570b1c5 100644 (file)
@@ -269,11 +269,11 @@ pub struct Execs {
     expect_stdin: Option<String>,
     expect_stderr: Option<String>,
     expect_exit_code: Option<i32>,
-    expect_stdout_contains: Vec<String>
+    expect_stdout_contains: Vec<String>,
+    expect_stderr_contains: Vec<String>,
 }
 
 impl Execs {
-
     pub fn with_stdout<S: ToString>(mut self, expected: S) -> Execs {
         self.expect_stdout = Some(expected.to_string());
         self
@@ -294,6 +294,11 @@ impl Execs {
         self
     }
 
+    pub fn with_stderr_contains<S: ToString>(mut self, expected: S) -> Execs {
+        self.expect_stderr_contains.push(expected.to_string());
+        self
+    }
+
     fn match_output(&self, actual: &Output) -> ham::MatchResult {
         self.match_status(actual)
             .and(self.match_stdout(actual))
@@ -321,6 +326,10 @@ impl Execs {
             try!(self.match_std(Some(expect), &actual.stdout, "stdout",
                                 &actual.stderr, true));
         }
+        for expect in self.expect_stderr_contains.iter() {
+            try!(self.match_std(Some(expect), &actual.stderr, "stderr",
+                                &actual.stdout, true));
+        }
         Ok(())
     }
 
@@ -475,7 +484,8 @@ pub fn execs() -> Execs {
         expect_stderr: None,
         expect_stdin: None,
         expect_exit_code: None,
-        expect_stdout_contains: vec![]
+        expect_stdout_contains: Vec::new(),
+        expect_stderr_contains: Vec::new(),
     }
 }
 
index afdfed8e8a347e4b40aa5638305c799f9e7215f4..288c44d86bd958b7ee19a6371bc44b811d3ceeb4 100644 (file)
@@ -223,10 +223,12 @@ test!(cargo_compile_with_invalid_code {
     assert_that(p.cargo_process("build"),
         execs()
         .with_status(101)
-        .with_stderr("\
+        .with_stderr_contains("\
 src[..]foo.rs:1:1: 1:8 error: expected item[..]found `invalid`
 src[..]foo.rs:1 invalid rust code!
              ^~~~~~~
+")
+        .with_stderr_contains("\
 Could not compile `foo`.
 
 To learn more, run the command again with --verbose.\n"));